<template>
  <div class="form_report">
    <!-- <dv-loading v-show="isLoading" class="loading">Loading...</dv-loading> -->
    <!-- <el-button @click="exportPdf" class="pdfBtn" v-show="!isLoading"
      >导出PDF</el-button
    > -->
    <div id="pdfDom1">
      <hp></hp>
      <clean></clean>
    </div>
    <div id="pdfDom2">
      <electromechanical></electromechanical>
      <water></water>
    </div>
  </div>
</template>
<script>
import apis from "@/api/api.js";
import water from "./module/Water";
import hp from "./module/Hp";
import clean from "./module/Clean";
import electromechanical from "./module/Em";
import ScrollTop from "../../../../components/ScrollTop";
import { setTimeout } from "timers";
export default {
  directives: {
    // clickDown: {
    //   inserted(el) {
    //     el.click();
    //   }
    // }
  },
  
  components: {
    water,
    hp,
    clean,
    electromechanical,
    ScrollTop,
  },
  data() {
    return {
      fileName1: "t4动力系统能源分析报告1-1",
      fileName2: "t4动力系统能源分析报告1-2",
      isLoading: true,
    };
  },
  async created() {
    //报警分析
    const queryPoliceAnalysisData = await apis.queryPoliceAnalysis();
    let queryPoliceAnalysisDesc = queryPoliceAnalysisData.data.content;
    // console.log(queryPoliceAnalysisDesc, "各科室报警分析描述");
    localStorage.setItem(
      "cleanList",
      JSON.stringify(queryPoliceAnalysisDesc.cleanList)
    );
    localStorage.setItem(
      "electromechanicalList",
      JSON.stringify(queryPoliceAnalysisDesc.electromechanicalList)
    );
    localStorage.setItem(
      "powerList",
      JSON.stringify(queryPoliceAnalysisDesc.powerList)
    );
    localStorage.setItem(
      "waterList",
      JSON.stringify(queryPoliceAnalysisDesc.waterList)
    );
  },
  mounted() {
    this.$nextTick(() => {
      setTimeout(() => {
        this.isLoading = false;
      }, 50000);
    });
    // // 当网页向下滑动 20px 出现"返回顶部" 按钮
    // window.onscroll = function() {
    //   scrollFunction();
    //   console.log(123);
    // };
    // function scrollFunction() {
    //   if (
    //     document.body.scrollTop > 20 ||
    //     document.documentElement.scrollTop > 20
    //   ) {
    //     document.getElementById("myBtn").style.display = "block";
    //   } else {
    //     document.getElementById("myBtn").style.display = "none";
    //   }
    // }
    // // 点击按钮，返回顶部
    // function topFunction() {
    //   document.body.scrollTop = 0;
    //   document.documentElement.scrollTop = 0;
    // }
    // document.getElementById("myBtn").onclick = function() {
    //   topFunction();
    // };
  },
  methods: {
    exportPdf() {
      this.getPdf("pdfDom1", this.fileName1);
      this.getPdf("pdfDom2", this.fileName2);
    },
    // goTopFn() {
    //   document.body.scrollTop = 0;
    //   document.documentElement.scrollTop = 0;
    // }
  },
};
</script>
<style lang="scss" scoped>
.pdfBtn {
  position: fixed;
  right: 20px;
  top: 10px;
}

// .goTop {
//   width: 80px;
//   height: 80px;
//   position: fixed;
//   cursor: pointer;
//   display: block;
//   right: 2%;
//   bottom: 6%;
//   background: url("../../../../assets/csot/arrow78.png") no-repeat center;
//   background-size: cover;
// }
</style>
